package net.servir.diagnostico.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import net.servir.diagnostico.model.IdentificacionParticipante;
import net.servir.diagnostico.model.jsp.JspBase;
import net.servir.diagnostico.service.DiagnosticoService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class MensajeFinalController {

	
	@Autowired
	private DiagnosticoService diagnosticoService;
		
	
	@RequestMapping("/mensajeFinal.htm")		
	public @ModelAttribute("mensajeFinal")
	JspBase  mensajeFinal(HttpServletRequest request) {
		
		JspBase base = new JspBase();
		
		IdentificacionParticipante identParticipante = null;
		
		HttpSession sesion = request.getSession();
		if (sesion.getAttribute("participante") == null)
		{
			//TODO: Redireccionar
		}
		else
			identParticipante = (IdentificacionParticipante)sesion.getAttribute("participante");
		
		identParticipante.setEvaluado(diagnosticoService.getEstadoEvaluacion(identParticipante.getId_participante()));
		
		base.setIdent_participante(identParticipante);
				
		return base;
	}
	
}
